package com.ljh.cvsspringboot.config;

import com.ljh.cvsspringboot.hander.SystemSessionHandler;
import jakarta.annotation.Resource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @author 27013
 **/

@Configuration//配置类

public class CoutomWebConfig implements WebMvcConfigurer {
    @Autowired
    private SystemSessionHandler systemSessionHandler;

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        //用于对哪些请求进行拦截
//        registry.addInterceptor(systemSessionHandler).addPathPatterns("/**")
//          //排除哪些请求不拦截
//                .excludePathPatterns("/toLogin","/register","/sys/login","/css/**", "/js/**","/images/**","/calendar/**")
//                ;
//    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
               registry.addViewController("/toLogin").setViewName("/login");
               registry.addViewController("/frame").setViewName("/frame");
    }

    /**
     * 配置静态资源处理器
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 前端请求路径 /statics/ 对应本地文件夹 /statics/ 静态文件资源的真实路径
        registry.addResourceHandler("/static/**")
                .addResourceLocations("/static/");
    }


}
